//这里才是真正存放请求函数的地方
import http from "./http.js";
import api from "./api.js";
//获取轮播图
export function getBanner(data) {
  return http({
    method: "GET",
    url: api.banner,
    params: data,
  });
}
export function getType(data) {
  return http({
    method: "GET",
    url: api.type,
    params: data,
  });
}
export function getGoods(data) {
  return http({
    method: "GET",
    url: api.goods,
    params: data,
  });
}
export function getGood(data, id) {
  return http({
    method: "GET",
    url: api.good + id,
    params: data,
  });
}

export function userLogin(data) {
  return http({
    method: "POST",
    url: api.login,
    data,
  });
}

export function getCart(data) {
  return http({
    method: "GET",
    url: api.cart,
    params: data,
  });
}

export function register(data) {
  return http({
    method: "POST",
    url: api.register,
    data,
  });
}

export function addCart(data) {
  return http({
    method: "POST",
    url: api.addCart,
    data,
  });
}

export function delCart(data, id) {
  return http({
    method: "DELETE",
    url: api.delCart + id,
    data,
  });
}

export function UpdateCart(data, id) {
  return http({
    method: "PUT",
    url: api.delCart + id,
    data,
  });
}
export function referOrder(data) {
  return http({
    method: "POST",
    url: api.order,
    data,
  });
}
export function getOrder(data) {
  return http({
    method: "GET",
    url: api.order,
    params: data,
  });
}
export function getCity(data) {
  return http({
    method: "GET",
    url: api.city,
    params: data,
  });
}
export function referAddress(data) {
  return http({
    method: "POST",
    url: api.address,
    data,
  });
}
export function getAddress(data) {
  return http({
    method: "GET",
    url: api.address,
    params: data,
  });
}

export function delOrder(data, id) {
  return http({
    method: "DELETE",
    url: api.delOrder + id,
    data,
  });
}
export function delAddress(data, id) {
  return http({
    method: "DELETE",
    url: api.delAddress + id,
    data,
  });
}
export function setDefault(data, id) {
  return http({
    method: "POST",
    url: api.setDefaultAddress + id,
    data,
  });
}
export function getDefault(data, id) {
  return http({
    method: "GET",
    url: api.defalutAddress,
    data,
  });
}
export function getGoodsSearch(data) {
  return http({
    method: "GET",
    url: api.goodsSearch,
    params: data,
  });
}
export function updateUser(data, id) {
  return http({
    method: "PUT",
    url: api.updateUser + id,
    data,
  });
}
